<?include dirname(__FILE__).'/../../include/js/table.builder.php' ?>
<h4><?php echo lang('Table Builder')?></h4>
<form name="tableBuilder" method="post" action="<?php echo common::url('table.builder.php')?>">
<input type="hidden" name="columns" value="" />
<input type="hidden" name="constraint" value="" />
<table border="0">
	<tr>
		<td><select name="columnList" size="10" style="width: 100%" onchange="columnList_onchange(this)"></select></td>
		<td valign="center"><button onclick="moveUp_onclick(); return false"><img src="images/arrow.up.gif" width="16" height="8" alt="<?php echo lang(' Move up')?>" vspace="4" /></button><br /><br /><button onclick="moveDown_onclick(); return false"><img src="images/arrow.down.gif" width="16" height="8" alt="<?php echo lang(' Move down')?>" vspace="4" /></button></td>
	</tr>
	<tr>
		<td align="center"><button style="width: 45%" name="addColumn" onclick="addColumn_onclick(); return false"><?php echo lang('Add Column')?></button>&nbsp;&nbsp;<button style="width: 45%" name="removeColumn" onclick="removeColumn_onclick(); return false"><?php echo lang('Remove Column')?></button></td>
		<td rowspan="4">&nbsp;</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td>
			<fieldset>
				<legend><?php echo lang('Column Properties')?></legend>
				<table border="0">
				<tr>
					<td><?php echo lang('Column Name:')?></td>
					<td colspan="2"><input type="text" name="columnName" value="" /></td>
				</tr>
				<tr>
					<td><?php echo lang('Column Type:')?></td>
					<td>
						<select name="columnType">
							<optgroup label="<?php echo lang('Textual Types')?>">
								<option value="varchar">VARCHAR</option>
								<option value="char">CHAR</option>
								<option value="text">TEXT</option>
				              		<option value="clob">CLOB</option>
								<option value="blob">BLOB</option>
							</optgroup>
							<optgroup label="<?php echo lang('Numeric Types')?>">
								<option value="integer">INTEGER</option>
								<option value="mediumint">MEDIUMINT</option>
								<option value="smallint">SMALLINT</option>
								<option value="tinyint">TINYINT</option>
								<option value="float">FLOAT</option>
								<option value="numeric">NUMERIC</option>
								<option value="decimal">DECIMAL</option>
							</optgroup>
							<optgroup label="<?php echo lang('Date/Time Types')?>">
								<option value="datetime">DATETIME</option>
								<option value="datetime">DATE</option>
								<option value="timestamp">TIMESTAMP</option>
							</optgroup>
							<optgroup label="<?php echo lang('Other Types')?>">
								<option value="boolean">BOOLEAN</option>
							</optgroup>
						</select>
					</td>
					<td><input type="text" value="" size="3" name="columnLength" /><?php echo lang('(Note: SQLite is <a href="http://www.sqlite.org/datatypes.html" target="_blank">typeless</a>!)')?></td>
				</tr>
				<tr>
					<td><?php echo lang('Default Value:')?></td>
					<td colspan="2"><input type="text" name="columnDefault" value="" /></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td colspan="2">
					<input type="checkbox" name="null" value="1" id="null" /><label for="null"><?php echo lang('Null')?></label></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td colspan="2"><input type="checkbox" name="constraint_primary" value="primary" id="constraint_primary" onclick="constraint_onclick('primary')" /><label for="constraint_primary"><?php echo lang('Primary Key')?></label></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input type="checkbox" name="constraint_unique" value="unique" id="constraint_unique" onclick="constraint_onclick('unique')" /><label for="constraint_unique"><?php echo lang('Unique')?></label></td>
					<td align="right"><button onclick="clearForm(); return false">Clear</button></td>
				</tr>
			   </table>
		   </fieldset>
		</td>
	</tr>
<tr>
	<td>&nbsp;</td>
</tr>
<tr>
	<td>
		<fieldset>
			<legend><?php echo lang('Table Properties')?></legend>
			<table border="0">
			<tr>
				<td><?php echo lang('Table Name:')?></td>
				<td><input type="text" name="tableName" value="" /></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td><input type="checkbox" name="temporary" value="1" id="temporary" /><label for="temporary"><?php echo lang('Temporary')?></label></td>
			</tr>
			</table>
		</fieldset>
	</td>
</tr>
<tr>
	<td align="right"><input type="submit" value="<?php echo lang('Add Table')?>" onclick="return addTable_onclick()" /></td>
</tr>
</table>
</form>